﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LJ.EventBus.FastDog.Data;

public readonly struct TransportMessage(IDictionary<string, string?> headers, ReadOnlyMemory<byte> body)
{

    /// <summary>
    /// Gets the headers of this message
    /// </summary>
    public IDictionary<string, string?> Headers { get; } = headers ?? throw new ArgumentNullException(nameof(headers));

    /// <summary>
    /// Gets the body object of this message
    /// </summary>
    public ReadOnlyMemory<byte> Body { get; } = body;

    public string GetId()
    {
        return Headers[MessageHeaders.MessageId]!;
    }

    public string GetName()
    {
        return Headers[MessageHeaders.MessageName]!;
    }

    public string? GetGroup()
    {
        return Headers.TryGetValue(MessageHeaders.Group, out var value) ? value : null;
    }

   
}